package com.freshman_registration.mapper;

import com.freshman_registration.pojo.Dormitorys;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

@Mapper
public interface DormitoryMapper {

    /* ----------- 原有单表方法保持不变 ----------- */
    int insert(Dormitorys dormitory);
    int updateByPrimaryKey(Dormitorys dormitory);
    Dormitorys selectByPrimaryKey(Integer id);
    List<Dormitorys> selectAll();

    /* ----------- 以下方法全部统一为驼峰参数 ----------- */

    int countAllocated(@Param("buildingNo") String buildingNo,
                       @Param("roomNo")   String roomNo);

    List<Integer> selectUsedBeds(@Param("buildingNo") String buildingNo,
                                 @Param("roomNo")   String roomNo);

    String selectGenderOfBuilding(@Param("buildingNo") String buildingNo);

    Dormitorys selectByStudentId(@Param("studentId") String studentId);

    int updateCheckIn(@Param("dormId") Long dormId,
                      @Param("checkInTime") Date checkInTime);

    Dormitorys findEmptyBedByGender(@Param("genderLimit") String genderLimit);

    int occupyBed(@Param("id") Long id, @Param("studentId") String studentId);

    /**
     * 多条件查询（统一驼峰）
     */
    List<Dormitorys> selectByCondition(@Param("buildingNo") String buildingNo,
                                       @Param("roomNo")     String roomNo,
                                       @Param("bedStatus")  String bedStatus,
                                       @Param("genderLimit") String genderLimit);

    int batchCheckOut(@Param("list") List<Long> dormIds);
    int batchDeleteByIds(@Param("list") List<Long> dormIds);

    int updateCheckInTime(@Param("dormId") Integer dormId,
                          @Param("checkInTime") Date checkInTime);

    Integer getDormIdByStudentId(@Param("studentId") String studentId);
    int insertBatch(@Param("building") String building,
                    @Param("room") String room,
                    @Param("gender") String gender,
                    @Param("beds") List<Integer> beds);
}